<template>
	<div class="allcontainer" v-loading="loading">
		<div class="h2">公示列表</div>
		<div class="bg-white">
			<div class="table">
				<el-table stripe ref="singleTable" :data="data" highlight-current-row style="width: 100%"
					@expand-change="hangClick">
					<el-table-column type="expand" prop="children">
						<template scope="scope">
							<el-table :data="scope.row.CreditApplyData">
								<el-table-column prop="No" label="编号" min-width="100" align="center"></el-table-column>
								<el-table-column prop="Title" label="名称" min-width="100"></el-table-column>
								<el-table-column prop="Name" label="状态/活动名称" min-width="240">
									<template slot-scope="scope">
										<a-tag color="red">{{ scope.row.StateName}}</a-tag>
										{{ scope.row.ActivityTypeName }}
									</template>
								</el-table-column>
								<el-table-column prop="ActivityTypePrizeName" label="奖项名称/类型" min-width="140"
									show-overflow-tooltip align="center">
									<template slot-scope="scope">
										{{ scope.row.ActivityTypePrizeName ||scope.row.MemberTypeName}}
									</template>
								</el-table-column>
								<el-table-column prop="Score" label="分值" min-width="80" align="right">
								</el-table-column>
								<el-table-column prop="AddTime" label="申请时间" min-width="140" align="center"></el-table-column>
								<el-table-column prop="IsEnable" label="操作" min-width="100" fixed="right">
									<template slot-scope="scope">

										<i title="驳回" class="iconfont icon-assist-cancel" v-if="isClassCharge"
											style="color: red;" @click="canceladmin(scope.row,4)"></i>
									</template>
								</el-table-column>
							</el-table>
						</template>
					</el-table-column>
					<el-table-column type="index" label="序号" width="60" fixed="left" align="center"></el-table-column>
					<el-table-column prop="TotalScore" label="申请人" min-width="100" align="center">
						<template slot-scope="scope">
							<a-tag color="green">{{ scope.row.UserNo }}/{{ scope.row.UserName }}</a-tag>
						</template>
					</el-table-column>
					<el-table-column prop="ClassName" label="班级" min-width="100" align="center"></el-table-column>
					<el-table-column prop="DepartName" label="部门/学院" min-width="100" align="center"></el-table-column>
					<el-table-column prop="TotalScore" label="总分" min-width="100" align="right"></el-table-column>
				</el-table>
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
					:current-page="pagination.currentPage" :page-sizes="pagination.pageSizeOptions"
					:page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
					:total="pagination.total"></el-pagination>
			</div>
		</div>
		<!-- <detail :approvalType="4" :time="time" :text="text" :ID="ClubID" :linktype="linktype" v-show="showModal" @closeFun="closeFun(1)"></detail> -->
	</div>
</template>

<script>
	import Func from '@/utils/func';
	import Cache from '@/utils/cache'
	import {
		UserCreditApplyDoGetPublicList,
		UserCreditApplyDoCancel
	} from '@/api/follow';
	// import detail from './detail'
	const data = [];
	export default {
		components: {
			//	detail
		},
		data() {
			return {
				isClassCharge: '',
				resourceC: [],
				ClassData: [],
				data,
				form: this.$form.createForm(this, {
					name: 'advanced_search'
				}),
				pagination: {
					currentPage: 1,
					pageSize: this.global.pageSize,
					pageSizeOptions: this.global.pageSizeOptions, // 每页中显示的数据
					showTotal: total => `共有 ${total} 条数据` // 分页中显示总的数据
				},
				addIf: false,
				text: {},
				visible: false,
				confirmLoading: false,
				itemId: '',
				departmentList: [],
				worklist: [],
				loading: false,
				values: {},
				pages: {
					pageIndex: 1,
					pageSize: 20
				},
				tableHeight: parseFloat(window.innerHeight - 160),
				TypeIDList: [],
				DepartCodeList: [],
				ProjectIDList: [],
				ishaveid: true,
				selectList: {},
				showModal: false,
				UserInfo: Cache.get('myInfo'),
				ChairmanNo: this.$route.query.ChairmanNo,
				linktype: 1,
				ClubID: this.$route.query.ID,
				visible: false,
				deletelist: {},
				time: ''
			};
		},
		computed: {},
		created() {
			this.getList();
			// this.getOtherList()
		},
		mounted() {},
		methods: {
			// setadmin(text) {
			// 	let data={}
			// 	data.
			// 	let res = await DoAddUserClubMember(data)
			// },
			hangClick(e) {
				// console.log(e);
				// this.resourceC = e.CreditApplyData;
			},
			canceladmin(text) {
				let that = this;
				this.$confirm({
					title: '提示',
					content: `您确定驳回该申请吗？`,
					okText: '确认',
					cancelText: '取消',
					async onOk() {
						let data = {};
						data.ID = text.ID
						let res = await UserCreditApplyDoCancel(data);
						if (res.data.code == 0) {
							that.getList();
							that.$message.success(res.data.msg);
						} else {
							that.$message.error(res.data.msg);
						}
					}
				});
			},
			handleCancel(e) {
				this.visible = false
				this.getList()
			},
			deletemember(text) {
				// this.visible = true
				// this.deletelist = text
				let that = this
				this.$confirm({
					title: '提示',
					content: `您确定删除该用户吗？`,
					okText: '确认',
					cancelText: '取消',
					async onOk() {
						let data = {}
						data.id = text.ID
						let res = await DoDeleteUserClubMember(data);
						if (res.data.code == 0) {
							that.getList()
							that.$message.success(res.data.msg)
						} else {
							that.$message.error(res.data.msg)
						}
					}
				})
			},
			detail(text, type) {
				this.linktype = type
				this.text = text
				this.time = new Date()
				this.showModal = true
			},
			handleChange(val) {
				this.currentRow = val;
				if (val.ID) {
					this.ishaveid = false
					this.selectList = val
				} else {
					this.ishaveid = true
				}
			},
			handleSearch(e) {
				e.preventDefault();
				this.form.validateFields((error, values) => {
					this.pagination.currentPage = 1;
					this.values = values;
					this.getList();
				});
			},
			handleReset() {
				this.form.resetFields();
				this.values = {};
				this.getList();
			},
			handleSizeChange(val) {
				this.pagination.pageSize = val;
				this.getList();
			},
			handleCurrentChange(val) {
				this.pagination.currentPage = val;
				this.getList();
			},
			async getList() {
				this.loading = true;
				let data = {};
				if (this.values) {
					data = this.values;
				}
				data.clubID = this.$route.query.ID
				data.pageIndex = this.pagination.currentPage;
				data.pageSize = this.pagination.pageSize;
				let res = await UserCreditApplyDoGetPublicList(data);
				this.loading = false;
				this.data = res.data.data;
				this.isClassCharge = res.data.isClassCharge
				// const pagination = { ...this.pagination
				// };
				// pagination.total = res.data.pageInfo.TotalItemCount;
				// this.pagination = pagination;
			},
			addList() {
				this.text = {};
				this.addIf = !this.addIf;
			},
			modifyList(text) {
				text = Object.assign(text, {
					time: new Date()
				});
				this.addIf = !this.addIf;
				this.text = text;
			},
			closeFun(index) {
				this.showModal = false
				this.getList()
			},
		}
	};
</script>
